version 8.0
log using samuels.log, replace
#delimit ;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      samuels.do                                      *;
*       Date:           11/14/04                                        *;
*       Author:         MG                                              *;
*       Purpose:        Replicate Samuels 2000                          *;
*       Input File:     samuels.dta                                     *;
*       Output File:    samuels.log                                     *;
*       Data Output:    none                                            *;
*       Previous file:                                                  *;
*       Machine:                                                        *;
*     ****************************************************************  *;
*     ****************************************************************  *;

set mem 10m;

set matsize 600;

use h:\politicalanalysis\replications\samuels\samuels.dta;

*     ****************************************************************  *;
*    Summary of data - this shows that we have the same data as Samuels *;
*     ****************************************************************  *;

sum enlists enpres engov;

*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*       Replicate results in Table 1                                    *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;

xi i.state;

*     ****************************************************************  *;
*       This is the closest I can get to the first model in Table 1     *;
*     ****************************************************************  *;

xi: regress  enlists logmag proxgov engov_proxgov proxpres enpres_proxpres     
    i.state year1945 year1947 year1954 year1958 year1962 year1994 year1998;
    
*     ****************************************************************  *;
*       Fully specified first model                                     *;
*     ****************************************************************  *;

xi: regress  enlists logmag proxgov engov engov_proxgov proxpres enpres enpres_proxpres     
    i.state year1945 year1947 year1954 year1958 year1962 year1994 year1998;
    
*     ****************************************************************  *;
*       This is the closest I can get to the second model in Table 1     *;
*     ****************************************************************  *;

xi: regress  enlists logmag proxgov engov_proxgov proxpres enpres_proxpres     
    i.state year1945 year1947 year1950 year1954 year1958 year1962  year1998;
    
*     ****************************************************************  *;
*       Fully specified second model                                    *;
*     ****************************************************************  *;

xi: regress  enlists logmag proxgov engov engov_proxgov proxpres enpres enpres_proxpres     
    i.state year1945 year1947 year1950 year1954 year1958 year1962 year1998; 
    
*     ****************************************************************  *;
*       This is the closest I can get to the third model in Table 1     *;
*     ****************************************************************  *;

xi: regress  enlists logmag proxgov engov_proxgov proxpres enpres_proxpres
         i.state year1945 year1947 year1950 year1954 year1958 year1962 year1994;
    
*     ****************************************************************  *;
*       Fully specified third model                                     *;
*     ****************************************************************  *;

xi: regress  enlists logmag proxgov engov engov_proxgov proxpres enpres enpres_proxpres
         i.state year1945 year1947 year1950 year1954 year1958 year1962 year1994;
         
        
         
*     ****************************************************************  *;
*                   Draw some conditional plots                         *;
*                   Gubernatorial Coat-tails - Model 1                  *;
*     ****************************************************************  *;

xi: regress  enlists  proxgov engov engov_proxgov proxpres enpres enpres_proxpres logmag     
    i.state year1945 year1947 year1954 year1958 year1962 year1994 year1998;


generate JH=((_n-1)/10);    

replace JH=. if _n>50;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<50;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<50;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=1.96*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*      Graph the effect of temporally-proximate gubernatorial elections *;
*      on effective number of electora lists.                           *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5, labsize(2.5)) 
            ylabel(-3 -2 -1 0 1 2 3, labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Temporally-Proximate Gubernatorial Elections (Model 1)") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of Temporally-Proximate Gubernatorial Elections", size(4))
            subtitle(" " "Dependent Variable: Effective Number of Electoral Lists" " ", size(3))
            xtitle(Effective Number of Gubernatorial Candidates, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Temporally-Proximate Gubernatorial Elections ", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        
        
*translate @Graph h:\politicalanalysis\replications\samuels\gubernatorial.eps;


*     ****************************************************************  *;
*       Presidential Coat-tails - Model 1                               *;
*     ****************************************************************  *;

drop top bottom conse conb JH a;

*     ****************************************************************  *;
*       Draw some conditional plots                                     *;
*     ****************************************************************  *;

xi: regress  enlists  proxpres enpres enpres_proxpres proxgov engov engov_proxgov 
    logmag  i.state year1945 year1947 year1954 year1958 year1962 year1994 year1998;


generate JH=((_n-1)/10);    

replace JH=. if _n>50;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<50;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<50;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=1.96*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of temporally-proximate presidential elections *;
*       on the effective number of electoral lists.                     *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5, labsize(2.5)) 
            ylabel(-2 -1 0 1 2 3 , labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Temporally-Proximate Presidential Elections") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of Temporally-Proximate Presidential Elections (Model 1)", size(4))
            subtitle(" " "Dependent Variable: Effective Number of Electoral Lists" " ", size(3))
            xtitle(Effective Number of Presidential Candidates, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Temporally-Proximate Presidential Elections ", size(3))
        scheme(s2mono) graphregion(fcolor(white));

*translate @Graph h:\politicalanalysis\replications\samuels\presidential.eps;

        

*     ****************************************************************  *;
*                   Gubernatorial Coat-tails - Model 2                  *;
*     ****************************************************************  *;

drop top bottom conse conb JH a;

xi: regress  enlists proxgov engov engov_proxgov proxpres enpres enpres_proxpres logmag     
    i.state year1945 year1947 year1950 year1954 year1958 year1962 year1998; 

generate JH=((_n-1)/10);    

replace JH=. if _n>50;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<50;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<50;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=1.96*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of temporally-proximate gubernatorial elections*;
*       on the effective number of electoral lists.                     *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5, labsize(2.5)) 
            ylabel(-3 -2 -1 0 1 2 3, labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Temporally-Proximate Gubernatorial Elections") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of Temporally-Proximate Gubernatorial Elections (Model 2)", size(4))
            subtitle(" " "Dependent Variable: Effective Number of Electoral Lists" " ", size(3))
            xtitle(Effective Number of Gubernatorial Candidates, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Temporally-Proximate Gubernatorial Elections ", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        
*translate @Graph h:\politicalanalysis\replications\samuels\gubernatorial2.eps;



*     ****************************************************************  *;
*       Presidential Coat-tails - Model 2                               *;
*     ****************************************************************  *;

drop top bottom conse conb JH a;

*     ****************************************************************  *;
*       Draw some conditional plots                                     *;
*     ****************************************************************  *;

xi: regress  enlists   proxpres enpres enpres_proxpres  logmag proxgov engov engov_proxgov   
    i.state year1945 year1947 year1950 year1954 year1958 year1962 year1998; 

generate JH=((_n-1)/10);    

replace JH=. if _n>50;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<50;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<50;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=1.96*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of temporally-proximate presidential elections *;
*       on the effective number of electoral lists.                     *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5, labsize(2.5)) 
            ylabel(-2 -1 0 1 2 3 , labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Temporally-Proximate Presidential Elections") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of Temporally-Proximate Presidential Electons (Model 2)", size(4))
            subtitle(" " "Dependent Variable: Effective Number of Electoral Lists" " ", size(3))
            xtitle(Effective Number of Presidential Candidates, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Temporally-Proximate Presidential Elections ", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        
*translate @Graph h:\politicalanalysis\replications\samuels\presidential2.eps;

        
*     ****************************************************************  *;
*                   Gubernatorial Coat-tails - Model 3                  *;
*     ****************************************************************  *;


drop top bottom conse conb JH a;

xi: regress  enlists  proxgov engov engov_proxgov proxpres enpres enpres_proxpres logmag
         i.state year1945 year1947 year1950 year1954 year1958 year1962 year1994;

generate JH=((_n-1)/10);    

replace JH=. if _n>50;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<50;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<50;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=1.96*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of temporally-proximate gubernatorial elections*;
*       on the effective number of electoral lists.                     *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5, labsize(2.5)) 
            ylabel(-3 -2 -1 0 1 2 3, labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Temporally-Proximate Gubernatorial Elections") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of Temporally-Proximate Gubernatorial Elections (Model 3)", size(4))
            subtitle(" " "Dependent Variable: Effective Number of Electoral Lists" " ", size(3))
            xtitle(Effective Number of Gubernatorial Candidates, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Temporally-Proximate Gubernatorial Elections", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        
*translate @Graph h:\politicalanalysis\replications\samuels\gubernatorial3.eps;


*     ****************************************************************  *;
*       Presidential Coat-tails - Model 3                               *;
*     ****************************************************************  *;

drop top bottom conse conb JH a;

*     ****************************************************************  *;
*       Draw some conditional plots                                     *;
*     ****************************************************************  *;

xi: regress  enlists  proxpres enpres enpres_proxpres proxgov engov engov_proxgov  logmag
         i.state year1945 year1947 year1950 year1954 year1958 year1962 year1994;

generate JH=((_n-1)/10);    

replace JH=. if _n>50;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<50;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<50;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=1.96*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of temporally-proximate presidential elections *;
*       on the effective number of electoral lists.                     *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5, labsize(2.5)) 
            ylabel(-2 -1 0 1 2 3 , labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Temporally-Proximate Presidential Elections (Model 3)") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of Temporally-Proximate Presidential Elections", size(4))
            subtitle(" " "Dependent Variable: Effective Number of Electoral Lists" " ", size(3))
            xtitle(Effective Number of Presidential Candidates, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Temporally-Proximate Presidential Elections", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        

*translate @Graph h:\politicalanalysis\replications\samuels\presidential3.eps;   


 exit;
